#pragma once


// ItemPanel dialog
#include "resource.h"
#include "ItemTabPanel.h"
#include <utility/EventHandler.h>
#include <utility/String.h>

namespace serika
{
	namespace dq
	{
		class EditItemDlg;
		class Item;

		class ItemListPanel : public CDialog, public ItemTabPanel, public ut::EventHandler
		{
			DECLARE_DYNAMIC(ItemListPanel)

		public:
			ItemListPanel(int itemType, CWnd* pParent = NULL);   // standard constructor
			virtual ~ItemListPanel();

			// Dialog Data
			enum { IDD = IDD_ITEMLISTPANEL };

			BOOL Create(CTabCtrl* parent);

			virtual void Activate();
			virtual void Deactivate();

			virtual void Handle(const ut::Event& e);

			void UpdateItem(int index, Item* item);

		protected:
			virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

			virtual BOOL OnInitDialog();
			DECLARE_MESSAGE_MAP()
			afx_msg void OnDoubleClickList(NMHDR* pNmhdr, LRESULT* pResult);
			afx_msg void OnDestroy();

			void CreateList();
			void RequestItemList();

			void OnItemList(const ut::Event& e);

		protected:
			CListCtrl mList;

			EditItemDlg* mEditItemDlg;

			int mItemType;

		private:
			void InsertCol(const ut::String& name, int width);

			void ShowEditItemDlg(int index, Item* item);
		};
	}
}

